#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;

typedef struct Tree {
        char ch;
        Tree * left, * right;
};

int n;
string a, b;

Tree * di(int al, int ar, int bl, int br) {
     Tree * node;
     int i;
     if (al > ar || bl > br || al>=n || bl>=n || ar>=n || br>=n) return NULL;
     if (al == ar) {
         node = new Tree();
         node->ch = a[al];
         node->left = node->right = NULL;
         //cout << "get " << a[al] << endl;
         return node;
     }
     node = new Tree();
     //cout << "get " << a[al] << endl;
     node->ch = a[al];
     //node->left = node->right = NULL;
     for (i=bl; i<=br; ++i)
         if (b[i] == a[al]) 
            break;
     node->left = di(al+1, al+i-bl, bl, i-1);
     node->right = di(al+i-bl+1, ar, i+1, br);
     return node;
}

void output(Tree * head) {
     if ( head == NULL) return ;
     output(head->left);
     output(head->right);
     cout << head->ch ;
}

int main()
{
    while (cin >> a >> b) {
          n = a.size();
          Tree * head = di(0, n-1, 0, n-1);
          output(head);
          cout << endl;
    }
    //system("pause");
    return 0;
}
/*
DBACEGF
ABCDEFG

GF
FG
*/
